﻿<?php 
session_start();
if ($_session['user_guid'] == "" || $_session['user_guid'] == null)
{
//	header("Location:login.php");
}
$guid = $_GET["guid"];
require_once '../bin/DBA/DB.class.php';
require_once '../bin/DAL/CategoriesDAL.php';
require_once '../bin/BLL/CategoriesBLL.php';
require_once '../bin/DAL/ProductsDAL.php';
require_once '../bin/BLL/ProductsBLL.php';
$chs_products = ProductsBLL::GetItemByChs_Products($guid);
$eng_products = ProductsBLL::GetItemByEng_Products($guid);
$deu_products = ProductsBLL::GetItemByDeu_Products($guid);
$chs_catename = CategoriesBLL::GetNameByChs_Categories($chs_products['classid']);
$eng_catename = CategoriesBLL::GetNameByEng_Categories($eng_products['classid']);
$deu_catename = CategoriesBLL::GetNameByDeu_Categories($deu_products['classid']);
$chs_categorie = CategoriesBLL::GetItemByChs_Categories();
$eng_categorie = CategoriesBLL::GetItemByEng_Categories();
$deu_categorie = CategoriesBLL::GetItemByDeu_Categories();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>无标题页</title>
    <link href="../Files/Css/products.css" rel="stylesheet" type="text/css" />
    <link href="../Files/Css/formpost.css" rel="stylesheet" charset="utf-8" type="text/css" />

    <script type="text/javascript" src="../Files/Javascript/jquery.js"></script>

    <script type="text/javascript" src="../Tools/tinymce/tinymce/tiny_mce.js"></script>

    <script language="javascript" type="text/javascript" src="../Tools/tinymce/editer.js"></script>

    <script type="text/javascript">
        $(function(){
            $(".content .main .record:last").addClass("nobor");
            
            //����Ǳ���ģ���Ӻ��Ǳ�ʶ.
            $("form :input.required").each(function(){
                var $required = $("<strong class='high'> *</strong>"); //����Ԫ��
                $(this).parent().append($required); //Ȼ����׷�ӵ��ĵ���
            });
             //�ı���ʧȥ�����
            $('form :input').blur(function(){
                 var $parent = $(this).parent();
                 $parent.find(".formtips").remove();
                 //��֤����
                 if( $(this).is('#txt_Name') ){
                        if( this.value=="" ){
                            var errorMsg = '请输入产品名称.';
                            $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
                        }else{
                            var okMsg = '输入正确.';
                            $parent.append('<span class="formtips onSuccess">'+okMsg+'</span>');
                        }
                 }
                 //��֤�����ַ
                 if( $(this).is('#file_Img') ){
                    if( this.value=="" ){
                          var errorMsg = '请上传文件.';
                          $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
                    }else{
                          var okMsg = '上传成功.';
                          $parent.append('<span class="formtips onSuccess">'+okMsg+'</span>');
                    }
                 }
                 //��֤����------����
                 if( $(this).is('#chs_select') ){
                    if( this.value=="0"){
                          var errorMsg = '请选择分类.';
                          $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
                    }
                 }
                 //��֤����------����
                 if( $(this).is('#art_content1') ){
                    if( this.val()==""){
                          var errorMsg = '请输入产品说明.';
                          $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
                    }
                 }
                 //��֤����------Ӣ��
                 if( $(this).is('#eng_select') ){
                    if( this.value=="0"){
                          var errorMsg = '请选择分类.';
                          $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
                    }
                 }
                 //��֤����------Ӣ��
                 if( $(this).is('#art_content2') ){
                    if( this.val()==""){
                          var errorMsg = '请输入产品说明.';
                          $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
                    }
                 }
                 //��֤����------����
                 if( $(this).is('#deu_select') ){
                    if( this.value=="0"){
                          var errorMsg = '请选择分类.';
                          $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
                    }
                 }
                 //��֤����------����
                 if( $(this).is('#art_content3') ){
                    if( this.val()==""){
                          var errorMsg = '请输入产品说明.';
                          $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
                    }
                 }
                 
            }).keyup(function(){
               $(this).triggerHandler("blur");
            }).focus(function(){
                 $(this).triggerHandler("blur");
            });//end blur

            
            //�ύ��������֤��
             $('#btn_sub').click(function(){
                    $("form :input.required").trigger('blur');
                    var numError = $('form .onError').length;
                    if(numError){
                        return false;
                    }
             });
        });
    </script>

</head>
<body>
    <form id="form1" method="post" action="EditProducts.server.php">
    <div class="container">
        <div class="content">
            <div class="head">
                <div class="title">
                    <ul>
                        <li></li>
                    </ul>
                </div>
                <div class="links">
                    <ul>
                        <li><a href="javascript:;"></a></li>
                    </ul>
                </div>
                <div id="clear">
                </div>
            </div>
            <div class="main">
                <div class="mid">
                    <div class="mid_content">
                        <table width="100%">
                            <tr>
                                <td colspan="2" align="left">
                                    <b>产品名称/上传图片</b>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    产品名称
                                </td>
                                <td align="left">
                                    <input id="txt_Name" type="text" name="txt_Name" size="60" value="<?php echo $chs_products['name']?>" class="required" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    上传图片
                                </td>
                                <td align="left">
                                    <input id="file_Img" type="file" name="file_Img" class="required" />
                                    [若要修改图片，请选择，否则不需要]
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="mid">
                    <div class="mid_content">
                        <table width="100%">
                            <tr>
                                <td colspan="2" align="left">
                                    <b>中文</b>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    产品分类
                                </td>
                                <td align="left">
                                    <select id="chs_select" name="chs_select" class="required">
	                                    <?php
	                                    for ($i=0;$i<count($chs_categorie);$i++){ 
	                                    ?>
	                                    <option value="<?php echo $chs_categorie['id']?>"><?php echo $chs_categorie['name']?></option>
	                                    <?php if($chs_categorie['name'] == $chs_catename){?>
                                        <option value="<?php echo $chs_categorie['id']?>" selected="selected"><?php echo $chs_categorie['name']?></option>
                                        <?php }}?>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    产品说明
                                </td>
                                <td align="left">

                                    <script type="text/javascript">Cediter("art_content1")</script>

                                    <textarea id="art_content1" name="art_content1" style="width: 600px; height: 350px;" class="required"><?php echo $chs_products['content'] ?></textarea>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="mid">
                    <div class="mid_content">
                        <table width="100%">
                            <tr>
                                <td colspan="2" align="left">
                                    <b>英文</b>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    产品分类
                                </td>
                                <td align="left">
                                    <select id="eng_select" name="eng_select" class="required">
                                         <?php
	                                    for ($i=0;$i<count($eng_categorie);$i++){ 
	                                    ?>
	                                    <option value="<?php echo $eng_categorie['id']?>"><?php echo $eng_categorie['name']?></option>
	                                    <?php if($eng_categorie['name'] == $eng_catename){?>
                                        <option value="<?php echo $eng_categorie['id']?>" selected="selected"><?php echo $eng_categorie['name']?></option>
                                        <?php }}?>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    产品说明
                                </td>
                                <td align="left">

                                    <script type="text/javascript">Cediter("art_content2")</script>

                                    <textarea id="art_content2" name="art_content2" style="width: 600px; height: 350px;" class="required"><?php echo $eng_products['content'] ?></textarea>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="mid">
                    <div class="mid_content">
                        <table width="100%">
                            <tr>
                                <td colspan="2" align="left">
                                    <b>德文</b>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    产品分类
                                </td>
                                <td align="left">
                                    <select id="deu_select" name="deu_select" class="required">
                                        <?php
	                                    for ($i=0;$i<count($deu_categorie);$i++){ 
	                                    ?>
	                                    <option value="<?php echo $deu_categorie['id']?>"><?php echo $deu_categorie['name']?></option>
	                                    <?php if($deu_categorie['name'] == $deu_catename){?>
                                        <option value="<?php echo $deu_categorie['id']?>" selected="selected"><?php echo $deu_categorie['name']?></option>
                                        <?php }}?>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    产品说明
                                </td>
                                <td align="left">

                                    <script type="text/javascript">Cediter("art_content3")</script>

                                    <textarea id="art_content3" name="art_content3" style="width: 600px; height: 350px;" class="required"><?php echo $deu_products['content'] ?></textarea>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="topost">
                    <input id="btn_sub" type="submit" value="提交数据" /></div>
            </div>
        </div>
        <div id="clear">
        </div>
    </div>
    </form>
</body>
</html>
